Listing 2 shows AddDataAtom , a routine that adds a data atom with an ID of dataAtomID as a child atom of tweenAtom . If dataSize is nonzero, then leaf data is copied from dataPtr to dataAtom . Otherwise (if dataContainer in not nil ), child atoms are copied from dataContainer . If you wish to add the actual data by using another routine, you may pass 0 in dataSize and nil in both dataPtr and dataContainer .
You can associate a tweener to be used as an interpolator for each dataAtom value. The interpolationTweenID parameter specifies the ID of a kTweenEntry atom that is a child of the newSequenceAtom returned by AddSequenceTweenAtom . If you specify an interpolation tweener, then the atTime parameter of the DoTween routine is first fed as an input to the interpolation tweener. The tweenResult of the interpolation tweener becomes the atTime parameter of the succeeding tweener. Note that the kTweenData atom and the kTweenInterpolationID atom have the same ID; this is how QuickTime groups them together.
For best performance, the output range of an interpolation tweener should be from 0 to the duration of the regular tweener. However, you may specify the minimum and maximum values that the interpolation tweener returns; this lets the tweener be shared. The minimum and maximum values are used to scale tweenResult , and are added as child atoms of a kTweenEntry in AddTweenAtom .
Listing 2 Utility routine AddDataAtom
OSErr AddDataAtom( QTAtomContainer container, QTAtom tweenAtom,
QTAtomID dataAtomID, long dataSize, Ptr dataPtr,
QTAtomContainer dataContainer, QTAtomID interpolationTweenID,
QTAtom *newDataAtom )
{
OSErr err = noErr;
QTAtom dataAtom = 0;
if ( (! container) || (dataAtomID == 0) || (dataSize &&
(dataContainer || !dataPtr)) ) { err = paramErr; goto bail; }
err = QTInsertChild( container, tweenAtom, kTweenData, dataAtomID, 0,
dataSize, dataPtr, &dataAtom );
if ( err ) goto bail;
if ( dataSize ) {
err = QTSetAtomData( container, dataAtom, dataSize, dataPtr );
if ( err ) goto bail;
}
else if ( dataContainer ) {
err = QTInsertChildren( container, dataAtom, dataContainer );
if ( err ) goto bail;
}
if ( interpolationTweenID ) {
err = QTInsertChild( container, tweenAtom, kTweenInterpolationID,
dataAtomID, 0, sizeof(interpolationTweenID),
&interpolationTweenID, nil );
if ( err ) goto bail;
}
bail:
if ( newDataAtom )
*newDataAtom = dataAtom;
return err;
}
| Previous | Chapter Contents | Chapter Top | Next |